logo
leafmap
85 gedi
Initializing search
    GitHub
    GitHub
    • Home
    • Book
    • Installation
    • Get Started
    • Usage
    • Web App
    • Tutorials
    • Contributing
    • FAQ
    • Changelog
    • YouTube Channel
    • Report Issues
      • basemaps module
      • bokehmap module
      • colormaps module
      • common module
      • deck module
      • deckgl module
      • examples module
      • foliumap module
      • kepler module
      • maplibregl module
      • leafmap module
      • legends module
      • map_widgets module
      • osm module
      • pc module
      • plot module
      • plotlymap module
      • deck module
      • stac module
      • toolbar module
      • FOSS4G 2021
      • SIGSPATIAL 2021
      • YouthMappers 2021
      • ICRW 2023
      • EarthCube 2023
      • Taiwan 2024
      • HGAC 2024
      • Overview
      • 3d buildings
      • 3d choropleth
      • 3d indoor mapping
      • 3d pmtiles
      • 3d style
      • 3d terrain
      • Add 3d buildings
      • Add a marker
      • Add colorbar
      • Add components
      • Add deckgl layer
      • Add gif
      • Add html
      • Add icon
      • Add image
      • Add image generated
      • Add legend
      • Add logo
      • Add text
      • Animate a line
      • Animate camera around point
      • Animate images
      • Animate point along line
      • Animate point along route
      • Attribution position
      • Basemaps
      • Center on symbol
      • Change building color
      • Change case of labels
      • Choropleth
      • Cloud optimized geotiff
      • Cluster
      • Color switcher
      • Countries filter
      • Custom marker
      • Data driven lines
      • Disable scroll zoom
      • Display rich text
      • Drag a marker
      • Draw features
      • Fallback image
      • Fields of the world
      • Fit bounds
      • Fill pattern
      • Fly to
      • Fly to options
      • Fullscreen
      • Geojson layer in stack
      • Geojson line
      • Geojson points
      • Geojson polygon
      • Geopandas
      • Google earth engine
      • Gps trace
      • Heatmap layer
      • Housing prices
      • Interactive false
      • Jump to
      • Language switch
      • Layer control
      • Line gradient
      • Live geojson
      • Live update feature
      • Local geojson
      • Local raster
      • Locate user
      • Map tiles
      • Maptiler styles
      • Mouse position
      • Multiple geometries
      • Navigation
      • Ocean bathymetry
      • Openfreemap
      • Openstreetmap
      • Overture
      • Pmtiles
      • Restrict bounds
      • Satellite map
      • Set pitch bearing
      • Stac
      • To html
      • Variable label placement
      • Variable offset label placement
      • Vector tile
      • Video on a map
      • Visualize population density
      • Wms source
      • Zoom to linestring
      • Usage
      • 01 leafmap intro
      • 02 using basemaps
      • 03 cog stac
      • 04 cog mosaic
      • 05 load raster
      • 06 legend
      • 07 colorbar
      • 08 whitebox
      • 09 csv to points
      • 10 add vector
      • 11 linked maps
      • 12 split map
      • 13 geopandas
      • 14 postgis
      • 15 openstreetmap
      • 16 heremap
      • 17 vector tile layer
      • 18 point layer
      • 19 map to html
      • 20 planet imagery
      • 21 ts inspector
      • 22 time slider
      • 23 colormaps
      • 24 heatmap
      • 25 map title
      • 26 kepler gl
      • 27 basemap gallery
      • 28 publish map
      • 29 pydeck
      • 30 census data
      • 31 search basemaps
      • 32 local tile
      • 33 image overlay
      • 34 add points from xy
      • 35 circle markers
      • 36 add labels
      • 37 planetary computer
      • 38 plotly
      • 39 inspector tool
      • 40 plotly gui
      • 41 raster gui
      • 42 create cog
      • 43 search control
      • 44 attribute table
      • 45 create vector
      • 46 edit vector
      • 47 numpy to cog
      • 48 lidar
      • 49 split control
      • 50 marker cluster
      • 51 clip image
      • 52 netcdf
      • 53 choropleth
      • 54 plot raster
      • 55 lidar
      • 56 download ned
      • 57 national map
      • 58 bokeh
      • 59 create legend
      • 60 add widget
      • 61 vector to gif
      • 62 folium colorbar
      • 63 arcgis
      • 64 stac search
      • 65 sagemaker
      • 66 gradio
      • 67 maxar open data
      • 68 openaerialmap
      • 69 turkey earthquake
      • 70 zonal stats
      • 71 aws s3
      • 72 timelapse
      • 73 custom stac
      • 74 map tiles to geotiff
      • 75 segment anything
      • 76 image comparison
      • 77 split raster
      • 78 read raster
      • 79 timeseries
      • 80 solar
      • 81 buildings
      • 82 pmtiles
      • 83 vector viz
      • 84 read parquet
      • 85 gedi
      • 86 add markers
      • 87 actinia
      • 88 nasa earth data
      • 89 image array viz
      • 90 pixel inspector
      • 91 raster viz gui
      • 92 maplibre
      • 93 maplibre pmtiles
      • 94 mapbox
      • 95 edit vector
      • 96 batch edit vector
      • 97 overture data
      • 98 watershed
      • 99 wetlands
      • 100 nlcd
      • 101 nasa opera

    image image image

    How to search and download GEDI L4A dataset interactively

    This notebook shows how to search and download the GEDI L4A dataset using leafmap. The source code is adapted from the gedi_tutorials repository but has been greatly simplified. Credit goes to ORNL DAAC and Rupesh Shrestha.

    Uncomment the following line to install leafmap if needed.

    In [1]:
    Copied!
    # %pip install -U "leafmap[vector]"
    
    # %pip install -U "leafmap[vector]"
    In [2]:
    Copied!
    from leafmap import leafmap
    
    from leafmap import leafmap

    Create an interactive map.

    In [3]:
    Copied!
    m = leafmap.Map(height=600)
    m
    
    m = leafmap.Map(height=600) m

    Use the draw tool to draw a rectangle on the map. If no rectangle is drawn, the default bounding box will be used.

    In [4]:
    Copied!
    if m.user_roi is not None:
        roi = m.user_roi_bounds()
    else:
        roi = [-73.9872, -33.7683, -34.7299, 5.2444]
    
    if m.user_roi is not None: roi = m.user_roi_bounds() else: roi = [-73.9872, -33.7683, -34.7299, 5.2444]

    Specify the start and end date.

    In [5]:
    Copied!
    start_date = "2020-07-01"
    end_date = "2020-07-31"
    
    start_date = "2020-07-01" end_date = "2020-07-31"

    Search and download GEDI L4A dataset.

    In [6]:
    Copied!
    gdf = leafmap.gedi_search(roi, start_date, end_date, add_roi=False, sort_filesize=True)
    gdf.head()
    
    gdf = leafmap.gedi_search(roi, start_date, end_date, add_roi=False, sort_filesize=True) gdf.head()
    Out[6]:
    id title time_start time_end granule_size granule_url granule_poly
    53 G2613724953-ORNL_CLOUD GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201881134... 2020-07-06T12:43:14.000Z 2020-07-06T12:46:58.000Z 47.861555 https://data.ornldaac.earthdata.nasa.gov/prote... MULTIPOLYGON (((-44.97207 2.55617, -42.81717 -...
    158 G2613715991-ORNL_CLOUD GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20202000651... 2020-07-18T08:01:01.000Z 2020-07-18T08:04:33.000Z 54.162131 https://data.ornldaac.earthdata.nasa.gov/prote... MULTIPOLYGON (((-42.53334 -0.01093, -40.37672 ...
    154 G2613746001-ORNL_CLOUD GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201992001... 2020-07-17T20:19:34.000Z 2020-07-17T20:24:35.000Z 55.751903 https://data.ornldaac.earthdata.nasa.gov/prote... MULTIPOLYGON (((-56.59662 -15.01064, -54.30646...
    86 G2613716275-ORNL_CLOUD GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20201921001... 2020-07-10T11:10:20.000Z 2020-07-10T11:14:01.000Z 57.355977 https://data.ornldaac.earthdata.nasa.gov/prote... MULTIPOLYGON (((-43.26376 0.03918, -41.10744 -...
    192 G2613743057-ORNL_CLOUD GEDI_L4A_AGB_Density_V2_1.GEDI04_A_20202040516... 2020-07-22T06:26:07.000Z 2020-07-22T06:29:35.000Z 60.549672 https://data.ornldaac.earthdata.nasa.gov/prote... MULTIPOLYGON (((-42.25131 0.03698, -40.09134 -...

    Visualize the GEDI L4A dataset footprints.

    In [7]:
    Copied!
    m.add_gdf(gdf, layer_name="GEDI footprints")
    m
    
    m.add_gdf(gdf, layer_name="GEDI footprints") m

    Download the GEDI L4A dataset from NASA EarthData website. You need to register an account first if you don't have one. Create an account at https://urs.earthdata.nasa.gov. Then return to this notebook and uncomment the following code cell to set your username and password.

    In [8]:
    Copied!
    # import os
    # os.environ["EARTHDATA_USERNAME"] = "your_username"
    # os.environ["EARTHDATA_PASSWORD"] = "your_password"
    
    # import os # os.environ["EARTHDATA_USERNAME"] = "your_username" # os.environ["EARTHDATA_PASSWORD"] = "your_password"
    In [9]:
    Copied!
    leafmap.gedi_download_files(gdf.head(), outdir="data")
    
    leafmap.gedi_download_files(gdf.head(), outdir="data")
    Downloading file 1 of 5...
    
    Downloading file 2 of 5...
    
    Downloading file 3 of 5...
    Downloading file 4 of 5...
    
    Downloading file 5 of 5...
    

    Read the downloaded GEDI L4A dataset as a GeoDataFrame.

    In [10]:
    Copied!
    try:
        gdf = leafmap.h5_to_gdf(
            "data/*.h5", dataset="BEAM0110", columns=["agbd"], nodata=-9999
        )
    except:
        # Download the sample data if the above code fails
        gdf = leafmap.geojson_to_gdf(
            "https://github.com/opengeos/data/releases/download/v1.0.0/gedi_sample.geojson"
        )
    gdf.head()
    
    try: gdf = leafmap.h5_to_gdf( "data/*.h5", dataset="BEAM0110", columns=["agbd"], nodata=-9999 ) except: # Download the sample data if the above code fails gdf = leafmap.geojson_to_gdf( "https://github.com/opengeos/data/releases/download/v1.0.0/gedi_sample.geojson" ) gdf.head()
    Out[10]:
    agbd lat_lowestmode lon_lowestmode category color geometry
    0 0.294734 -6.611691 -38.467288 1 #f7fcf5 POINT (-38.46729 -6.61169)
    1 0.698346 -6.614202 -38.465479 1 #f7fcf5 POINT (-38.46548 -6.6142)
    2 0.377637 -6.704764 -38.400342 1 #f7fcf5 POINT (-38.40034 -6.70476)
    3 0.655570 -6.705182 -38.400042 1 #f7fcf5 POINT (-38.40004 -6.70518)
    4 6.617977 -6.708118 -38.397930 3 #74c476 POINT (-38.39793 -6.70812)

    We can subset the GeoDataFrame by a bounding box. First, create an interactive map and add the bounding box to the map.

    In [11]:
    Copied!
    m = leafmap.Map(height=620)
    roi = [-38.8641, -6.8664, -37.2107, -6.359]
    bbox = leafmap.bbox_to_gdf(roi)
    m.add_gdf(bbox, layer_name="ROI", zoom_to_layer=True, info_mode=None)
    m
    
    m = leafmap.Map(height=620) roi = [-38.8641, -6.8664, -37.2107, -6.359] bbox = leafmap.bbox_to_gdf(roi) m.add_gdf(bbox, layer_name="ROI", zoom_to_layer=True, info_mode=None) m

    Use the bounding box to subset the GeoDataFrame.

    In [12]:
    Copied!
    subset = leafmap.filter_bounds(gdf, roi, within=True)
    
    subset = leafmap.filter_bounds(gdf, roi, within=True)

    Add the subsetted GeoDataFrame to the map. Note that this is only for visualizing a small subset of the data. If you want to work with the entire dataset, you can skip this step.

    In [13]:
    Copied!
    m.add_data(subset, column="agbd", cmap="Greens", marker_radius=5)
    
    m.add_data(subset, column="agbd", cmap="Greens", marker_radius=5)

    Visualize the GEDI L4A Aboveground Biomass Density (AGBD) data with lonboard.

    In [14]:
    Copied!
    import leafmap
    
    import leafmap
    In [15]:
    Copied!
    leafmap.view_vector(
        gdf, color_column="agbd", color_map="Greens", color_k=10, get_radius=25
    )
    
    leafmap.view_vector( gdf, color_column="agbd", color_map="Greens", color_k=10, get_radius=25 )
    2024-09-01 2021-03-10
    Copyright © 2021 - 2024 Qiusheng Wu
    Made with Material for MkDocs